/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package swing.tree;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 *
 * @author Administrator
 */
public class DefaultTreeNodeDemo
{
  public static void main(String[] args)
  {
    JFrame frame = new JFrame("TreeNode Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
    DefaultMutableTreeNode mercuy = new DefaultMutableTreeNode("mercuy");
    root.insert(mercuy, 0);
    DefaultMutableTreeNode venus = new DefaultMutableTreeNode("Venus");
    root.insert(venus, 1);
    DefaultMutableTreeNode mars = new DefaultMutableTreeNode("Mars");
    root.insert(mars, 2);
    JTree tree = new JTree(root);
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.add(scrollPane);
    frame.setSize(300, 300);
    frame.setVisible(true);
  }
}
